package info.cs52.fes.prolog;

import alice.tuprolog.Library;
import alice.tuprolog.Struct;
import alice.tuprolog.Term;

public class KnowledgeLibrary extends Library {

	private StringBuilder kb;

	public KnowledgeLibrary(String initialKnowledge) {
		kb = new StringBuilder(initialKnowledge);
	}
	
	public void addKnowledge(String s) {
		kb.append(s).append(".\n");
	}

	public boolean add_knowledge_1(Struct s) {
		kb.append(s).append(".\n");
		return true;
	}
	
	public String getKnowledge() {
		return kb.toString();
	}
	
	private String question = null;

	public boolean ask_1(Term attrib) {
		if (question == null) {
			question = attrib.toString();
			question = question.split("/")[1].trim();
		}
		return true;
	}
	
	public String getQuestion() {
		return question;
	}
		
}
